// 斐波那契数列
<template>
  <div>
    <prism language="javascript">
      function* fbnq() {
      //斐波那契数列
      let [now, next] = [0, 1]; //结构赋值
      while (true) {
      yield now;
      [now, next] = [next, now + next];
      }
      }
      for (let i of fbnq()) {
      if (i > 10000) break;
      console.log(i);
    </prism>
    <v-btn
      round
      color="success"
      @click="run"
    >
      RUN
    </v-btn>
  </div>
</template>

<script>
import Prism from "vue-prism-component";
export default {
  components: {
    Prism
  },
  methods: {
    run() {
      function* fbnq() {
        //斐波那契数列
        let [now, next] = [0, 1]; //结构赋值
        while (true) {
          yield now;
          [now, next] = [next, now + next];
        }
      }
      for (let i of fbnq()) {
        if (i > 10000) break;
        console.log(i);
      }
    }
  }
};
</script>